package net.sf.midollo.net.httptunnel.client;

import java.io.IOException;
import java.net.URL;

import net.sf.midollo.io.IOStream;
import net.sf.midollo.io.IOStreamFactory;

public class HttpTunnelClientIOStreamFactory implements IOStreamFactory {

  protected final URL url;
  protected final IOStreamFactory ioStreamFactory;

  public HttpTunnelClientIOStreamFactory(URL url, IOStreamFactory ioStreamFactory) {
    this.url = url;
    this.ioStreamFactory = ioStreamFactory;
  }

  public IOStream open() throws IOException {
    HttpTunnelConnection connection = new HttpTunnelConnection(this.url, this.ioStreamFactory);
    return new HttpTunnelClientIOStream(connection);
  }
}
